package com.zt.dev.processMonitoring.service.impl;

import com.zt.dev.processMonitoring.mapper.ProcessMonitoringMapper;
import com.zt.dev.processMonitoring.pojo.ProcessMonitoring;
import com.zt.dev.processMonitoring.pojo.TestNode;
import com.zt.dev.processMonitoring.service.ProcessMonitoringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 卜德凯
 * @date 2020/2/25 18:43
 */
@Service
public class ProcessMonitoringServiceImpl implements ProcessMonitoringService {


    @Autowired
    private ProcessMonitoringMapper processMonitoringMapper;

    /**
     * 添加预期进度
     * @param expectedPlan
     * @return
     */
    @Override
    public Integer insertExpectedPlan(String expectedPlan) {
        return processMonitoringMapper.insertExpectedPlan(expectedPlan);
    }

    /**
     * 根据id获取数据库已有的实验数据
     * @param id
     * @return
     */
    @Override
    public ProcessMonitoring findExperimentalPlanById(Integer id) {
        return processMonitoringMapper.findExperimentalPlanById(id);
    }

    /**
     * 更新实验进度和实验完成时间
     * @param experimentalPlan
     * @param completionTime
     * @param id
     * @return
     */
    @Override
    public Integer updateExperimentalPlan(String experimentalPlan,String completionTime,Integer id) {
        return processMonitoringMapper.updateExperimentalPlan(experimentalPlan,completionTime,id);
    }

    /**
     * 添加节点
     * @param testNodeList
     * @return
     */
    @Override
    public Integer addTestNode(List<TestNode> testNodeList) {
        return processMonitoringMapper.addTestNode(testNodeList);
    }

    /**
     * 1.根据id修改节点状态
     * private Integer status;//节点状态（每个节点的）（0未开始、1执行中、2已完成）
     * 2.根据id修改节点的实际完成时间和完成情况描述
     * private String actualEndTime;//实际完成时间（每个节点的）
     * private String describe;//完成情况描述（每个节点的）
     * @param testNode
     * @return
     */
    @Override
    public Integer updateNodeState(TestNode testNode) {
        return processMonitoringMapper.updateNodeState(testNode);
    }

    /**
     * 获得所有已有进程的试验
     * @return
     */
    @Override
    public List<ProcessMonitoring> findPageTPM() {
        return processMonitoringMapper.findPageTPM();
    }

    /**
     * 根据试验id查看具体进程
     * @param pId
     * @return
     */
    @Override
    public List<TestNode> viewProcess(Integer pId) {
        return processMonitoringMapper.viewProcess(pId);
    }
}
